

startinstr "Create multischema xml file"

wasuser = node[:was][:user]
wasgroup = node[:was][:group]
wasuserpw = node[:was][:userpw]
cuser = node[:chef][:user]
cgroup = node[:chef][:group]
deployment = node[:deployment]

runtdbhost=""
search(:node, "deployment:#{deployment}").each do |anode|
	#anode.each do|role|
	#	puts "Checking role " + role
	#end
	if anode.role?("om_runtdb2")
		runtdbhost = anode[:fqdn]
	end
end

if runtdbhost == ""
	raise "OMS Runtime DB Host node not available !"
end 
template "/tmp/multischema.xml" do
  source "multischema.xml.erb"
  owner wasuser
  group wasgroup
  variables(:omdbuser => node[:om][:omdbuser],
            :omdbname => node[:om][:omdbname],
            :omdbuserpasswd => node[:db2][:password],
            :omdbhost =>  runtdbhost,
            :omdbport => node[:om][:omdbport],
            :omdbschemaowner => node[:om][:omdbschemaowner],
            :omdbconfigschemaowner => node[:om][:omdbconfigschemaowner],
            :omdbstatschemaowner => node[:om][:omdbstatschemaowner],
            :omdbtranschemaowner => node[:om][:omdbtranschemaowner],
            :omdbdfbischemaowner => node[:om][:omdbdfbischemaowner],
            :omdbstgbischemaowner => node[:om][:omdbstgbischemaowner],
            :ominstalllocation => node[:om][:installlocation],
            :omruntimedir => node[:om][:omruntimedir],
            :omdbmasterschemaowner => node[:om][:omdbmasterschemaowner])
  action :create
end

stopinstr "Create multischema xml file"
